package com.zpdhy.summer.guice.service.impl;

import com.google.inject.Provider;
import com.zpdhy.summer.guice.annotation.Output;
import com.zpdhy.summer.guice.service.MyApplet;
import com.zpdhy.summer.guice.service.MyDestination;

import javax.inject.Inject;

/**
 * Created by Administrator on 2017/11/21.
 */
public class StringWritingApplet implements MyApplet {

    private MyDestination destination;

    private Provider<String> stringProvider;

    @Inject
    public StringWritingApplet(MyDestination destination,@Output Provider<String> stringProvider) {
        super();
        this.destination = destination;
        this.stringProvider = stringProvider;
    }

    private void writeString() {
        destination.write(stringProvider.get());
    }

    @Override
    public void run() {
        writeString();
    }
}
